#打包 镜像  在目录 docker build  -t  syss:v123165 -f  hrm_system/Dockerfile  .
FROM maven:3.8.6-openjdk-8-slim AS build
USER root
WORKDIR /opt
ARG appName=hrm_system
COPY ./ .
# 镜像容器目录~/.m2/  挂载到宿主机目录 /opt/maven
VOLUME ["/opt/maven","~/.m2"]
RUN /usr/share/maven/bin/mvn clean package -DskipTests=true -pl $appName -am

#FROM jdk8
FROM java:8-jdk
# Set the timezone.
RUN echo "Asia/Chongqing" > /etc/timezone
RUN dpkg-reconfigure -f noninteractive tzdata
# Make logs dir
ARG appName=hrm_system
RUN mkdir -p /opt/$appName
# Add the jar and run
# 从上一个build把 jar复制出来
COPY --from=build  /opt/$appName/target/*.jar  /opt/$appName/app.jar
WORKDIR /opt/$appName
ENTRYPOINT ["java","-XX:+UseG1GC","-XX:MaxGCPauseMillis=100","-Xmx1024m","-Xms128m","-XX:+HeapDumpOnOutOfMemoryError", "-XX:HeapDumpPath=/logs","-Djava.security.egd=file:/dev/./urandom","-jar","app.jar"]
EXPOSE 6061
